<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏商家合作平台</title>
    <script src="__JS__/jquery.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
</head>
<body>
<br/>
<div style="width: 500px;margin: 0 auto">
    <label id="info" style="display: none;color: red;text-align: center"></label>
    <form class="layui-form" id="myform" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">昵称</label>
            <div class="layui-input-block">
                <input type="text" name="nickname" required  lay-verify="required" value="{$Think.session.business.name}" placeholder="昵称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">联系人</label>
            <div class="layui-input-block">
                <input type="text" name="linkman" required  lay-verify="required" value="{$Think.session.business.linkman}" placeholder="联系人(必填)" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="telephone" required  lay-verify="required" value="{$Think.session.business.telephone}" placeholder="联系电话(必填)" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">收款账号</label>
            <div class="layui-input-block">
                <input type="text" name="paymentaccount" required  lay-verify="required" value="{$Think.session.business.paymentaccount}" placeholder="收款账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">所属银行</label>
            <div class="layui-input-block">
                <input type="text" name="bank" required  lay-verify="required" value="{$Think.session.business.bank}" placeholder="所属银行" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px">支行</label>
            <div class="layui-input-block">
                <input type="text" name="branch" required  lay-verify="required" value="{$Think.session.business.branch}" placeholder="支行" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text" style="width: 300px;margin: 0 auto;">
            <div class="layui-input-block" >
                <button type="button" id="update" class="btn btn-primary">修改</button>
                <button type="button" id="cancel" class="btn btn-default">取消</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>
    //取消修改
    $("#cancel").click(function () {
        //获取窗口索引
        var index = parent.layer.getFrameIndex(window.name);
        //关闭弹出的子页面窗口
        parent.layer.close(index);
    });
    //修改跟人信息
    $("#update").click(function () {
        var linkman = $("input[name=linkman]").val();
        if(!linkman){
            $("#info").html('请添加联系人');
            $("#info").css('display','block');
            return;
        }
        var telephone = $("input[name=telephone]").val();
        if(!telephone){
            $("#info").html('前添加练习电话');
            $("#info").css('display','block');
            return;
        }
        $.ajax({
           url:"{:url('business/common/update')}",
           data:$("#myform").serialize(),
           type:"post",
           dataType:"json",
           success:function (res) {
               if(res.success){
                   layer.alert(res.success,{bnt:['确定']},function () {
                       //获取窗口索引
                       var index = parent.layer.getFrameIndex(window.name);
                       //关闭弹出的子页面窗口
                       parent.layer.close(index);
                       //刷新
                       window.parent.location.reload();
                   })
               }
               if(res.error){
                   $("#info").html(res.error);
                   $("#info").css('display','block');
                   return;
               }
           }
        });
    });
</script>
</html>